package com.sunshine_brid.ccras_server.service.dao;

import static com.sunshine_brid.ccras_server.service.support.EntityMenuDynamicSqlSupport.*;

import com.sunshine_brid.ccras_server.service.entity.EntityMenu;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.CommonCountMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonDeleteMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonInsertMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonUpdateMapper;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface EntityMenuMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<EntityMenu>, CommonUpdateMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    BasicColumn[] selectList = BasicColumn.columnList(projectId, project, tierId, tier, entityId, entity);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="EntityMenuResult", value = {
        @Result(column="project_id", property="projectId", jdbcType=JdbcType.INTEGER),
        @Result(column="project", property="project", jdbcType=JdbcType.VARCHAR),
        @Result(column="tier_id", property="tierId", jdbcType=JdbcType.INTEGER),
        @Result(column="tier", property="tier", jdbcType=JdbcType.VARCHAR),
        @Result(column="entity_id", property="entityId", jdbcType=JdbcType.INTEGER),
        @Result(column="entity", property="entity", jdbcType=JdbcType.VARCHAR)
    })
    List<EntityMenu> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("EntityMenuResult")
    Optional<EntityMenu> selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, entityMenu, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, entityMenu, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(EntityMenu row) {
        return MyBatis3Utils.insert(this::insert, row, entityMenu, c ->
            c.map(projectId).toProperty("projectId")
            .map(project).toProperty("project")
            .map(tierId).toProperty("tierId")
            .map(tier).toProperty("tier")
            .map(entityId).toProperty("entityId")
            .map(entity).toProperty("entity")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertMultiple(Collection<EntityMenu> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, entityMenu, c ->
            c.map(projectId).toProperty("projectId")
            .map(project).toProperty("project")
            .map(tierId).toProperty("tierId")
            .map(tier).toProperty("tier")
            .map(entityId).toProperty("entityId")
            .map(entity).toProperty("entity")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(EntityMenu row) {
        return MyBatis3Utils.insert(this::insert, row, entityMenu, c ->
            c.map(projectId).toPropertyWhenPresent("projectId", row::getProjectId)
            .map(project).toPropertyWhenPresent("project", row::getProject)
            .map(tierId).toPropertyWhenPresent("tierId", row::getTierId)
            .map(tier).toPropertyWhenPresent("tier", row::getTier)
            .map(entityId).toPropertyWhenPresent("entityId", row::getEntityId)
            .map(entity).toPropertyWhenPresent("entity", row::getEntity)
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<EntityMenu> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, entityMenu, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<EntityMenu> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, entityMenu, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<EntityMenu> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, entityMenu, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, entityMenu, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateAllColumns(EntityMenu row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(projectId).equalTo(row::getProjectId)
                .set(project).equalTo(row::getProject)
                .set(tierId).equalTo(row::getTierId)
                .set(tier).equalTo(row::getTier)
                .set(entityId).equalTo(row::getEntityId)
                .set(entity).equalTo(row::getEntity);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(EntityMenu row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(projectId).equalToWhenPresent(row::getProjectId)
                .set(project).equalToWhenPresent(row::getProject)
                .set(tierId).equalToWhenPresent(row::getTierId)
                .set(tier).equalToWhenPresent(row::getTier)
                .set(entityId).equalToWhenPresent(row::getEntityId)
                .set(entity).equalToWhenPresent(row::getEntity);
    }
}